/*
*       A simple 2D game map editor
*
*       This library is free software; you can redistribute it and/or
*       modify it under the terms of the GNU Lesser General Public
*       License as published by the Free Software Foundation; either
*       version 2.1 of the License, or (at your option) any later version.
*/
// Name        : tilewidget
// File        : widget_tile.h
// Description :
// Author      : hoha
// Date        : 01/07/2009
// Evolutions  : 01/07/2009, Version V0, Creation
#ifndef WIDGET_TILESET_H
#define WIDGET_TILESET_H

#include <QWidget>
#include <QtGui/QWidget>
#include <QPainter>
#include <QPixmap>
#include <QString>
#include <QMouseEvent>
#include "tileset.h"

#define START_MARGINX 20
#define START_MARGINY 20
#define TILE_SPACE_WIDTH (64+10)
#define TILE_SPACE_HEIGHT (32+10)
#define RENDER_RANGE 24
#define NS_SELECTED_TILE 0xFFFF;

typedef struct{
        int picPosX;
        int picPosY;
        int txtPosX;
        int txtPosY;
}wt_tileRender_t;

extern int selected_tileId;
class Wt_TileSet : public QWidget
{
        Q_OBJECT
        public:
            Wt_TileSet(QWidget *parent = 0);
            ~Wt_TileSet();
            virtual void paintEvent(QPaintEvent *event);
            virtual void mousePressEvent(QMouseEvent *event);
            //virtual void mouseMoveEvent(QMouseEvent *event);
        public:
            wt_tileRender_t tileRender[MAX_TILE_PER_TILESET];
            int render_beginTile;
            int render_endTile;

        public:
            void set_widget_size();
            void init_tileRender();
            void init_render_tileRange();            
            int   cac_tileId(int screenX, int screenY);
            void update_selected_tileId(int screenX, int screenY);
            void draw_tiles(QPainter *painter);
            void mark_selected_tile(QPainter *painter);
            bool check_selected_tileId_valid();
        public slots:
            void update_render_tileRange(int scrollbarValue);

        private:
};
#endif // WIDGET_TILESET_H
